package com.wry.wry_test.demo;

import com.alibaba.fastjson.JSON;
import com.wry.wry_test.model.excel.Plugin;
import com.wry.wry_test.utils.CsvUtil;

import java.io.File;
import java.util.List;

/**
 * @Author: wangrongyi
 * @Date: 2025/1/22 15:58
 * @Description:
 */
public class CsvDemo {

    public static void main(String[] args) {
        String path = "E:\\plugins.csv";
        File file = new File(path);
        List<Plugin> plugins = CsvUtil.read(",", file, Plugin.class);
        System.out.println(plugins);
        for (Plugin plugin : plugins) {
            try {
                String json = plugin.getJson();
                int start = json.indexOf("description") + 15;
                int end = json.indexOf("headers") - 5;
                String s = json.substring(start, end);
                String description = s.replace("\\n", "");
                String sql = "UPDATE PLUGIN SET description = '" + description + "' WHERE name = '" + plugin.getName() + "';";
                System.out.println(sql);
            } catch (Exception e) {

            }


        }


    }



}
